package com.eduhzy.ttw.teacher.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.teacher.R;
import com.eduhzy.ttw.teacher.mvp.contract.ContactContract;
import com.eduhzy.ttw.teacher.mvp.model.ContactModel;
import com.eduhzy.ttw.teacher.mvp.model.entity.ChildAreaData;
import com.jess.arms.di.scope.FragmentScope;
import com.mcxtzhang.indexlib.suspension.SuspensionDecoration;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * @author xubo
 * @date 2018-7-20 14:48:38
 */
@Module
public abstract class ContactModule {

    @Binds
    abstract ContactContract.Model bindContactModel(ContactModel model);

    @FragmentScope
    @Provides
    static List<ChildAreaData> provideList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static BaseQuickAdapter<ChildAreaData, AutoBaseViewHolder> provideActivityAdapter(List<ChildAreaData> list) {
        return new BaseQuickAdapter<ChildAreaData, AutoBaseViewHolder>(R.layout.rv_item_contact, list) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ChildAreaData item) {
                helper.setText(R.id.tv_name, item.getAreaName());
                helper.setGone(R.id.btn_count, item.isShowCount());
            }
        };
    }

    @FragmentScope
    @Provides
    static SuspensionDecoration provideSuspensionDecoration(ContactContract.View view, List<ChildAreaData> list) {
        return new SuspensionDecoration(view.getActivity(), list);
    }

    @FragmentScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManger(ContactContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }
}